<template>
  <div class="count-card" @click="showTable">
    <div class="count-card-left">
      <div v-if="props.info.type==='img'" class="count-card-icon">
        <img style="width: 40px;height: 40px;" :src="props.info.icon"/>
      </div>
      <div v-else class="count-card-icon" :class="'icon-' + props.info.icon"></div>
      <div class="count-card-title">
        <div class="title-zh">{{ props.info.zh }}<span style="font-size: 14px;font-weight: 400;color: rgba(255,255,255,0.6);font-family: '微软雅黑'; line-height: 20px;margin-left: 8px;opacity: 0.5;">{{props.info.unit}}</span></div>
        <div class="title-en">{{ toUpper(props.info.en) }}</div>
      </div>
    </div>
    
  </div>
</template>
<script setup>
import mCountTo from "@/components/mCountTo/index.js"
import {defineEmits} from "vue"
const props = defineProps({
  info: {
    type: Object,
    default: () => {
      return {
        icon: "xiaoshoujine",
        zh: "2023年销售金额",
        en: "Sales amount in 2023",
        value: 9500,
        unit: "万元",
        decimals: 0,
      }
    },
  },
  isNeedClick:{
    type:Boolean,
    default:false
  }

})
const emit = defineEmits(['showTable','hideTable']);
function toUpper(text) {
  return text.toUpperCase()
}
const showTable = (data)=>{
  if(props.isNeedClick){
    console.log(props.info.en)
    let index = props.info.en==='供应链金融支持我省重点产业链规模'?3:2
    emit('showTable', index); // 触发事件并传递数据
  }
}
const hideTable = (data)=>{
  emit('hideTable', data); // 触发事件并传递数据
}
</script>
<style lang="scss">
.count-card {
  // display: flex;
  // align-items: center;
  cursor: pointer;

  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  pointer-events: all;
  justify-content: center;

  &-left {
    display: flex;
    align-items: center;
  }
  &-right {
    display: flex;
    align-items: center;
    padding-left: 20px;
    .value {
      font-family: D-DIN;
      font-weight: bold;
      font-size: 28px;
      color: #ffffff;
      letter-spacing: 1px;
      margin-right: 10px;
      text-shadow: 0px 0px 18px rgba(255, 255, 255, 0.7);
      white-space: nowrap;
    }
    .unit {
      font-weight: 500;
      font-size: 12px;
      color: #ffffff;
      padding-top: 15px;
      opacity: 0.5;
      white-space: nowrap;
    }
  }
  &-icon {
    width: 40px;
    height: 40px;
    margin-right: 5px;
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 100%;
    // 2023销售金额
    &.icon-xiaoshoujine {
      background-image: url("~@/assets/images/icon1.png");
    }
    // 2023总销量
    &.icon-zongxiaoliang {
      background-image: url("~@/assets/images/icon2.png");
    }
  }
  &-title {
    .title-zh {
      font-weight: bold;
      font-size: 20px;
      line-height: 22px;
      font-family: "Douyu";
      color: #ffffff;
      white-space: nowrap;
    }
    .title-en {
      font-family: D-DIN;
      font-weight: 400;
      font-size: 12px;
      color: #A1C2F9;
      // padding-top: 5px;
      line-height: 17px;
      white-space: nowrap;
    }
  }
}
</style>
